#ifndef CTPINTERFACE_H
#define CTPINTERFACE_H

#include <QObject>
#include"ThostFtdcMdApi.h"
#include"ThostFtdcMdSpiImpl.h"
#include"ThostFtdcTraderApi.h"
#include"ThostFtdcTraderSpiImpl.h"
#include"../CommUtil/common.h"
#include<QDir>
#include<QMessageBox>
#include<QTime>
#include<Windows.h>

class CTPInterface : public QObject
{
    Q_OBJECT
public:
    explicit CTPInterface(QObject *parent = 0);

    bool InitTradeObject(QString strUserName,QString strPassword,QString strBrokerID,QString strServerName);
    bool InitMdObject(QString strUserName,QString strPassword,QString strBrokerID);

    void SubscribeMarketData(QStringList lst);
    bool ReqQryInstrument();
    bool ReqQrySettlementInfoConfirm();
    void ReqQryTradingAccount();

    void ReqSettlementInfoConfirm();
    ///撤销委托
    void DeleteOrder(TThostFtdcOrderSysIDType& entrust_no,TThostFtdcExchangeIDType& ExchangeID);
    ///请求查询成交
    void ReqQryTrade();
    ///请求查询合约保证金率
    void ReqQryInstrumentMarginRate(QString InstrumentID,TThostFtdcHedgeFlagType  HedgeFlag);
    ///请求查询投资者持仓
    void ReqQryInvestorPosition();
    void OrderInsert(const char* exch_type, const char* contract_code,
                                   char c_bs, char c_direction, char c_hedge,
                                   int l_entrust_amount, double en_entrust_price,QString entrust_prop);
    //CTP服务器的配置信息
	QString ServerName;
	QString ServerTradeAddr;
	QString ServerMarketAddr;
signals:

public slots:

private:
	QStringList					m_SubscribeCodesLst;

    CThostFtdcMdApi*            m_pmdUserApi;
    CThostFtdcTraderApi*        m_pTradeUserApi;
    CThostFtdcMdSpiImpl*        m_pThostFtdcMdSpiImpl;
    CThostFtdcTraderSpiImpl*    m_pThostFtdcTraderSpiImpl;

};

#endif // CTPINTERFACE_H
